#ifndef YUVPLAYER_H
#define YUVPLAYER_H

extern "C" {

    #include <libavutil/imgutils.h>
}

#include <QWidget>
#include <QFile>
#include <QDebug>
struct YUVSpec{

  int width;
  int height;
  int fps;
  AVPixelFormat format;
  const char* filePath;
};

class YUVPlayer : public QWidget
{
    Q_OBJECT
public:

    enum State{

        Playing,
        Pause,
        Stop
    };

    explicit YUVPlayer(QWidget *parent = nullptr);
    ~YUVPlayer();
    int init(YUVSpec &yuvSpec);
    void start();
signals:

private:
    YUVSpec yuvSpec;
    int timer = 0;
    State state = Stop;
    QFile* inFile = nullptr;
    int imageSize = 0;
    char* imageBuffer = nullptr;
    QImage* image = nullptr;

    void timerEvent(QTimerEvent* event);
    void paintEvent(QPaintEvent* event);
};

#endif // YUVPLAYER_H
